$(function() {
	$('<input type="text" id="query"/>&nbsp;<button id="btnSearch" type="button">Search</button><span id="indicatorSearch"></span>').appendTo('#search');

	$('#btnSearch').click(function() {
		$('#indicatorSearch').html(fffCommerce.ui.indicator + ' Loading, please wait...');
		$('#list').empty();
		fffCommerce.api.Products.browse($('#query').val(), function(e) {
			$('#indicatorSearch').empty();
			if (e.data) {
				$('body').trigger(fffCommerce.events.SHOW_LIST, [e.data]);
			} else {
				$('#list').html('<b>Error:</b> ' + e.error);
			}
		});
	}, false);
});